package com.securitytrace.client.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.apache.log4j.Logger;

import com.securitytrace.client.Manager;
import com.securitytrace.client.RFIDManagerFactory;
import com.securitytrace.client.ui.MainFrame;
import com.securitytrace.client.ui.MainFrameFactory;

public class MainFrameStartButtonListener implements ActionListener{

	private static final Logger logger = Logger.getLogger(MainFrameStartButtonListener.class);
	
	MainFrame mainFrame = MainFrameFactory.getMainFrame();

	@Override
	public void actionPerformed(ActionEvent e) {
		logger.debug("点击启动服务按钮");
		mainFrame.getStartButton().setEnabled(false);
		mainFrame.getStopButton().setEnabled(true);
		
		if(mainFrame.getSelectProductComboBox() != null){
			mainFrame.getSelectProductComboBox().setEnabled(false);
		}
		
//		String selectedItem = mainFrame.getSelectProductComboBox().getSelectedItem().toString();
		String frontText = mainFrame.getOptionTextArea().getText();
		
		Manager manager = RFIDManagerFactory.getInstance();
		manager.start();
		
		mainFrame.getOptionTextArea().setText(frontText+"服务已经成功启动,可以登记信息了！\n");
	}
}
